package com.sumainfor.pc.market.service;

import com.alibaba.fastjson.JSONObject;
import com.sumainfor.common.Constants;
import com.sumainfor.common.util.ContextUtils;
import com.sumainfor.common.util.CustomMap;
import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.*;
import com.sumainfor.pc.market.dao.*;
import com.sumainfor.pc.market.feign.BaseFeignZuul;
import com.sumainfor.pc.market.feign.GmioFeign.GmioFeign;
import com.sumainfor.pc.market.feign.Zfeign.ZzuulFeign;
import com.sumainfor.pc.market.feign.ZuulFeign.ZuulFeign;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 功能描述:
 * 房源信息
 *
 * @Auther: zhlu
 * @Date: 2018/12/15 15:04
 * @Description:
 */
@Service
public class HousingService {
    private ReentrantLock lock = new ReentrantLock(false);

    Logger log = LoggerFactory.getLogger(HousingService.class);

    @Autowired
    UtilsMapper utilsMapper;

    @Autowired
    HousingMapper housingMapper;
    @Autowired
    HousingOwnerMapper housingOwnerMapper;
    @Autowired
    HousingOwnersMapper housingOwnersMapper;
    @Autowired
    ProfitMapper profitMapper;

    @Autowired
    OwnerMapper OwnerMapper;

    @Autowired
    BaseFeignZuul baseFeignZuul;

    @Autowired
    private ZzuulFeign zuulFeign;

    @Autowired
    private ZuulFeign feignZull;

    @Autowired
    GmioFeign GmioFeign;

    String UUID = null;

    String HouOwId = null;

    /**
     * 功能描述:
     * 获取盈利预测中已通过审核的房源
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2018/12/15 15:06
     */
    public Map<String, Object> getProfitHousing(Map<String, Object> params) {
        Map<String, Object> getProfitHousing = housingMapper.getProfitHousing(params);
        if (!StringUtils.isBlank(MapUtils.getString(getProfitHousing, "BuilDing"))) {
            if (StringUtils.isBlank(MapUtils.getString(getProfitHousing, "Room"))) {
                getProfitHousing.put("BuilDingRoom", getProfitHousing.get("BuilDing").toString() + "号");
            } else {
                getProfitHousing.put("BuilDingRoom", getProfitHousing.get("BuilDing").toString() + "号" + getProfitHousing.get("Room").toString() + "室");
            }
        } else {
            getProfitHousing.put("BuilDingRoom", null);
        }
        getProfitHousing.put("HouIdz", getProfitHousing.get("ComCod").toString() + getProfitHousing.get("Road").toString() + getProfitHousing.get("BuilDing").toString() + getProfitHousing.get("Room").toString() + "Z");

        //判断img集合是否有值
        if (!FieldCheckUtil.isMapFieldNotNull(getProfitHousing, new String[]{"DeedFile"})) {
            getProfitHousing.put("DeedFile", new ArrayList<>());
        } else {
            getProfitHousing.put("DeedFile", getProfitHousing.get("DeedFile").toString().split(","));
        }
        if (!FieldCheckUtil.isMapFieldNotNull(getProfitHousing, new String[]{"HouImg"})) {
            getProfitHousing.put("HouImg", new ArrayList<>());
        } else {
            getProfitHousing.put("HouImg", getProfitHousing.get("HouImg").toString().split(","));
        }
        if (!FieldCheckUtil.isMapFieldNotNull(getProfitHousing, new String[]{"ContractFile"})) {
            getProfitHousing.put("ContractFile", new ArrayList<>());
        } else {
            getProfitHousing.put("ContractFile", getProfitHousing.get("ContractFile").toString().split(","));
        }
        if (!FieldCheckUtil.isMapFieldNotNull(getProfitHousing, new String[]{"RestsFile"})) {
            getProfitHousing.put("RestsFile", new ArrayList<>());
        } else {
            getProfitHousing.put("RestsFile", getProfitHousing.get("RestsFile").toString().split(","));
        }
        //判断img集合是否有值

        //判断是否有房源编号。然后去查询房源其他业主资料和业主物品
        if (!FieldCheckUtil.isMapFieldNotNull(getProfitHousing, new String[]{"HouId"})) {
            getProfitHousing.put("ownerList", new ArrayList<>());
            getProfitHousing.put("owners", new ArrayList<>());
        } else {
            List<Map<String, Object>> getHousingOwnerList = housingOwnerMapper.getHousingOwnerList(new HashMap<String, Object>() {{
                put("HouId", getProfitHousing.get("HouId"));
                put("delfg", 0);
            }});
            for (Map<String, Object> map : getHousingOwnerList) {

                if(!getProfitHousing.get("IdnoImgs").toString().isEmpty()){
                String Rests = getProfitHousing.get("IdnoImgs").toString();
                List<Map<String, Object>> IdnoImgs = FileSubufferUtils.StringTranListUtils(Rests);
                map.put("IdnoImgs", IdnoImgs);
                }
            }
            getProfitHousing.put("ownerList", getHousingOwnerList);


            List<Map<String, Object>> getHousingOwners = housingOwnersMapper.getHousingOwners(new HashMap<String, Object>() {{
                put("HouId", getProfitHousing.get("HouId"));
                put("delfg", 0);
            }});
            getProfitHousing.put("owners", getHousingOwners);
        }
        return getProfitHousing;
    }

    /**
     * 功能描述:
     * 新增收房信息
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2018/12/18 11:48
     */
    @Transactional(rollbackFor = Exception.class)
    public Map<String, Object> AddHousing(Map<String, Object> params) {
        Map<String, Object> result = new HashMap<String, Object>();
        /**
         * 加锁操作
         */
        lock.lock();
        try {
            //查询房源编号
            Map<String, Object> uuid = utilsMapper.getUUID(new HashMap<String, Object>() {{
                put("uuid", "HouId");
                put("database", Constants.DATA_SOURCE_TCMKT);
                put("surface", "tcmkt_housing");
            }});
            if (uuid != null) {
                int number = Integer.valueOf(uuid.get("uuid").toString());
                UUID = ComUtils.getLocalTrmSeqNum("fy", number);
            } else {
                UUID = ComUtils.getLocalTrmSeqNum("fy", 0);
            }
            //查询房源业主
            Map<String, Object> houOwId = utilsMapper.getUUID(new HashMap<String, Object>() {{
                put("uuid", "HouOwId");
                put("database", Constants.DATA_SOURCE_TCMKT);
                put("surface", "tcmkt_housing_owner");
            }});
            if (houOwId != null) {
                int number = Integer.valueOf(houOwId.get("uuid").toString());
                HouOwId = ComUtils.getLocalTrmSeqNum("fyow", number);
            } else {
                HouOwId = ComUtils.getLocalTrmSeqNum("fyow", 0);
            }

            //所有新增处理
            Map<String, Object> commonInsertParms = new HashMap<String, Object>();
            commonInsertParms.put("by", ContextUtils.getUserId());//操作人
            commonInsertParms.put("HouId", UUID);//项目编号等于项目名称加路号
            commonInsertParms.put("term", "2");// 创建端 Insert端： 1 租客端 2市场部 3 工程部   4运营部   5财务部  6总经办 7发展部
            commonInsertParms.put("fnc",
                    this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
            ParamsCommon.commonInsertParms(commonInsertParms);

            //所有修改处理
//            Map<String,Object>commonUpdateParms=new HashMap<String,Object>();
//            commonUpdateParms.put("by", ContextUtils.getUserId());//操作人
//            commonUpdateParms.put("term", "2");// 创建端 Insert端： 1 租客端 2市场部 3 工程部   4运营部   5财务部  6总经办 7发展部
//            commonUpdateParms.put("fnc",
//                    this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
//            ParamsCommon.commonUpdateParms(commonUpdateParms);
            try {
                //房产证不动产照片
                List<Map<String, Object>> DeedFileList = (List<Map<String, Object>>) params.get("DeedFile");
                String DeedFile = FileSubufferUtils.ListTranStringUtils(DeedFileList);
                params.put("DeedFile", DeedFile);
                //房源照片
                List<Map<String, Object>> HouImgList = (List<Map<String, Object>>) params.get("HouImg");
                String HouImg = FileSubufferUtils.ListFlieStringUtils(HouImgList);
                params.put("HouImg", HouImg);
                //合同照片
                List<Map<String, Object>> ContractFileList = (List<Map<String, Object>>) params.get("ContractFile");
                String ContractFile = FileSubufferUtils.ListTranStringUtils(ContractFileList);
                params.put("ContractFile", ContractFile);
                //其他文件
                List<Map<String, Object>> RestsFileList = (List<Map<String, Object>>) params.get("RestsFileList");
                String RestsFile = FileSubufferUtils.ListTranStringUtils(ContractFileList);
                params.put("RestsFile", RestsFile);

//                log.info("params-----"+params);
                params.putAll(commonInsertParms);
                //房源收录人编号
                params.put("InclusionId", commonInsertParms.get("insby"));
                //新增收房资料
                housingMapper.AddHousing(params);

                //根据业主编号查询当前业主合同
                Map<String, Object> getOwnerDealOwIdMap = OwnerMapper.getOwnerDealOwIdMap(new HashMap<String, Object>() {{
                    put("OwId", params.get("OwId"));
                }});

                //根据业主合同编号录入业主合同附件及业主收款人
                OwnerMapper.UpdateOwnerDeal(new HashMap<String, Object>() {{
                    put("OwDeId", getOwnerDealOwIdMap.get("OwDeId"));
                    put("FirstPayment", params.get("FirstPayment"));
                    put("SecondPayment", params.get("SecondPayment"));
                    put("Payee", params.get("Payee"));
                    put("PayBank", params.get("PayBank"));
                    put("PayAccount", params.get("PayAccount"));
                    put("ContractFile", ContractFile);
                }});

                //根据业主合同编号获取业主合同资料，生成业主账单
                Map<String, Object> getOwnerDealMap = OwnerMapper.getOwnerDealMap(new HashMap<String, Object>() {{
                    put("OwDeId", getOwnerDealOwIdMap.get("OwDeId"));
                }});

                //生成业主账单
                GmioFeign.AddBillOwner(getOwnerDealMap);

                //房源业主其他资料
                List<Map<String, Object>> ownerList = (List<Map<String, Object>>) params.get("ownerList");
                for (Map<String, Object> map : ownerList) {
                    List<Map<String, Object>> IdnoImgsList = (List<Map<String, Object>>) map.get("IdnoImgs");
                    String IdnoImgs = FileSubufferUtils.ListTranStringUtils(IdnoImgsList);
                    map.put("IdnoImgs", IdnoImgs);
                    log.info("map----" + map);
                    map.putAll(commonInsertParms);
                    map.put("HouOwId", HouOwId);
                    map.put("HouId", UUID);
                    housingOwnerMapper.AddHousingOwner(map);
                }

                //房源业主物品
                List<Map<String, Object>> owners = (List<Map<String, Object>>) params.get("owners");
                if (owners.size() > 0) {
                    for (Map<String, Object> map : owners) {
                        if (!map.get("Number").equals(0)) {
                            map.put("HouId", UUID);
                            map.putAll(commonInsertParms);
                            housingOwnersMapper.AddHousingOwners(map);
                        }
                    }
                }

                //修改盈利预测编号
                profitMapper.updateProfit(new HashMap<String, Object>() {{
                    put("ProId", params.get("ProId"));
                    put("FirstPayment", params.get("FirstPayment"));
                    put("SecondPayment", params.get("SecondPayment"));
                    put("ProState", 6);//状态 状态 1草稿 2待审核 3驳回 4审核通过 5放弃（失效） 6房源收录草稿箱
                }});


                //根据业主编号和房源编号清空当前业主-租金递增周期
                OwnerMapper.DeleteOwnerRent(new HashMap<String, Object>() {{
                    put("OwId", params.get("OwId"));
                    put("HouId", UUID);
                }});


                //业主租金变化时间点
                List<String> ownerDeal1 = (List<String>) params.get("ownerDeal1");
                log.info("ownerDeal1----" + ownerDeal1);
                for (String str : ownerDeal1) {
                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("OwId", params.get("OwId"));
                    map.put("HouId", UUID);
                    map.put("Increasing", 1);//递增周期类型    1.租金变化时间点   2.原始租金   3.递增后租金
                    map.put("Worth", str);
                    map.put("Operator", ContextUtils.getUserId());
                    map.put("OperTime", ConvertDateTime.getCurrentTime());
                    map.putAll(commonInsertParms);
                    //新增业主-租金递增周期
                    OwnerMapper.AddOwnerRent(map);
                }
                //原始租金
                List<Integer> ownerDeal2 = (List<Integer>) params.get("ownerDeal2");
                log.info("ownerDeal2----" + ownerDeal2);
                for (Integer str : ownerDeal2) {
                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("OwId", params.get("OwId"));
                    map.put("HouId", UUID);
                    map.put("Increasing", 2);//递增周期类型    1.租金变化时间点   2.原始租金   3.递增后租金
                    map.put("Worth", str);
                    map.put("Operator", ContextUtils.getUserId());
                    map.put("OperTime", ConvertDateTime.getCurrentTime());
                    map.putAll(commonInsertParms);
                    //新增业主-租金递增周期
                    OwnerMapper.AddOwnerRent(map);
                }
                //增涨租金
                List<Integer> ownerDeal3 = (List<Integer>) params.get("ownerDeal3");
                log.info("ownerDeal3----" + ownerDeal3);
                for (Integer str : ownerDeal3) {
                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("OwId", params.get("OwId"));
                    map.put("HouId", UUID);
                    map.put("Increasing", 3);//递增周期类型    1.租金变化时间点   2.原始租金   3.递增后租金
                    map.put("Worth", str);
                    map.put("Operator", ContextUtils.getUserId());
                    map.put("OperTime", ConvertDateTime.getCurrentTime());
                    map.putAll(commonInsertParms);
                    //新增业主-租金递增周期
                    OwnerMapper.AddOwnerRent(map);
                }

                result.put("HouId", UUID);
                result.put("status", 0);
            } catch (Exception e) {
                e.printStackTrace();
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            }
        } finally {
            lock.unlock();
        }
        return result;
    }

    /**
     * 功能描述:
     * 房源列表
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2018/12/18 17:57
     */
    public List<Map<String, Object>> getHousingList(Map<String, Object> params) {
        List<Map<String, Object>> getHousingList = housingMapper.getHousingList(params);
        for (Map<String, Object> map : getHousingList) {
            if (!StringUtils.isBlank(MapUtils.getString(map, "BuilDing"))) {
                if (StringUtils.isBlank(MapUtils.getString(map, "Room"))) {
                    map.put("BuilDingRoom", map.get("BuilDing").toString() + "号");
                } else {
                    map.put("BuilDingRoom", map.get("BuilDing").toString() + "号" + map.get("Room").toString() + "室");
                }
            } else {
                map.put("BuilDingRoom", null);
            }

            if (!StringUtils.isBlank(MapUtils.getString(map, "OwLoculus"))) {
                if (!StringUtils.isBlank(MapUtils.getString(map, "OwHall"))) {
                    if (!StringUtils.isBlank(MapUtils.getString(map, "OwGuard"))) {
                        map.put("house", map.get("OwLoculus").toString() + "室" + map.get("OwHall").toString() + "厅" + map.get("OwGuard").toString() + "卫");
                    } else {
                        map.put("house", map.get("OwLoculus").toString() + "室" + map.get("OwHall").toString() + "厅");
                    }
                } else {
                    map.put("house", map.get("OwLoculus").toString() + "室");
                }
            } else {
                map.put("house", null);
            }
        }
        return getHousingList;
    }

    /**
     * 功能描述:
     * 房源列表总数
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2018/12/18 17:57
     */
    public Integer getHousingListCount(Map<String, Object> params) {
        Integer getHousingListCount = housingMapper.getHousingListCount(params);
        return getHousingListCount;
    }

    /**
     * 功能描述:
     * 根据房源编号获取房源资料
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2018/12/19 10:02
     */
    public Map<String, Object> getHousingMap(Map<String, Object> params) {
        Map<String, Object> getHousingMap = housingMapper.getHousingMap(params);
        if (!StringUtils.isBlank(MapUtils.getString(getHousingMap, "BuilDing"))) {
            if (StringUtils.isBlank(MapUtils.getString(getHousingMap, "Room"))) {
                getHousingMap.put("BuilDingRoom", getHousingMap.get("BuilDing").toString() + "号");
            } else {
                getHousingMap.put("BuilDingRoom", getHousingMap.get("BuilDing").toString() + "号" + getHousingMap.get("Room").toString() + "室");
            }
        } else {
            getHousingMap.put("BuilDingRoom", null);
        }
        getHousingMap.put("HouIdz", getHousingMap.get("ComCod").toString() + getHousingMap.get("Road").toString() + getHousingMap.get("BuilDing").toString() + getHousingMap.get("Room").toString() + "Z");
        //判断img集合是否有值
        if (!FieldCheckUtil.isMapFieldNotNull(getHousingMap, new String[]{"DeedFile"})) {
            getHousingMap.put("DeedFile", new ArrayList<>());
        } else {
            String Rests = getHousingMap.get("DeedFile").toString();
            List<Map<String, Object>> DeedFile = FileSubufferUtils.StringTranListUtils(Rests);
            getHousingMap.put("DeedFile", DeedFile);
        }
        if (!FieldCheckUtil.isMapFieldNotNull(getHousingMap, new String[]{"HouImg"})) {
            getHousingMap.put("HouImg", new ArrayList<>());
        } else {
            String Rests = getHousingMap.get("HouImg").toString();
            List<Map<String, Object>> HouImg = FileSubufferUtils.StringFlieListUtils(Rests);
            getHousingMap.put("HouImg", HouImg);
        }
        if (!FieldCheckUtil.isMapFieldNotNull(getHousingMap, new String[]{"ContractFile"})) {
            getHousingMap.put("ContractFile", new ArrayList<>());
        } else {
            String Rests = getHousingMap.get("ContractFile").toString();
            List<Map<String, Object>> ContractFile = FileSubufferUtils.StringTranListUtils(Rests);
            getHousingMap.put("ContractFile", ContractFile);
        }
        if (!FieldCheckUtil.isMapFieldNotNull(getHousingMap, new String[]{"RestsFile"})) {
            getHousingMap.put("RestsFile", new ArrayList<>());
        } else {
            String Rests = getHousingMap.get("RestsFile").toString();
            List<Map<String, Object>> RestsFile = FileSubufferUtils.StringTranListUtils(Rests);
            getHousingMap.put("RestsFile", RestsFile);
        }

        List<Map<String, Object>> getHousingOwnerList = housingOwnerMapper.getHousingOwnerList(new HashMap<String, Object>() {{
            put("HouId", getHousingMap.get("HouId"));
            put("delfg", 0);
        }});

        for (Map<String, Object> map : getHousingOwnerList) {
            log.info("map-----" + map);
            String Rests = map.get("IdnoImgs").toString();
            List<Map<String, Object>> IdnoImgs = FileSubufferUtils.StringTranListUtils(Rests);
            String NameIdno = map.get("HouOwName") + "-" + map.get("IdnoNumber");
            map.put("NameIdno", NameIdno);
            map.put("IdnoImgs", IdnoImgs);
        }
        getHousingMap.put("ownerList", getHousingOwnerList);

        List<Map<String, Object>> getHousingOwners = housingOwnersMapper.getHousingOwners(new HashMap<String, Object>() {{
            put("HouId", getHousingMap.get("HouId"));
            put("delfg", 0);
        }});
        getHousingMap.put("owners", getHousingOwners);

        //业主租金变化时间点
        List<String> ownerDeal1 = OwnerMapper.getOwnerRent(new HashMap<String, Object>() {{
            put("OwId", getHousingMap.get("OwId"));
            put("HouId", getHousingMap.get("HouId"));
            put("Increasing", 1);//递增周期类型    1.租金变化时间点   2.原始租金   3.递增后租金
        }});

        //原始租金
        List<String> ownerDeal2 = OwnerMapper.getOwnerRent(new HashMap<String, Object>() {{
            put("OwId", getHousingMap.get("OwId"));
            put("HouId", getHousingMap.get("HouId"));
            put("Increasing", 2);//递增周期类型    1.租金变化时间点   2.原始租金   3.递增后租金
        }});

        //增涨租金
        List<String> ownerDeal3 = OwnerMapper.getOwnerRent(new HashMap<String, Object>() {{
            put("OwId", getHousingMap.get("OwId"));
            put("HouId", getHousingMap.get("HouId"));
            put("Increasing", 3);//递增周期类型    1.租金变化时间点   2.原始租金   3.递增后租金
        }});

        getHousingMap.put("ownerDeal1", ownerDeal1);
        getHousingMap.put("ownerDeal2", ownerDeal2);
        getHousingMap.put("ownerDeal3", ownerDeal3);

        return getHousingMap;
    }

    /**
     * 功能描述:
     * 修改房源信息及业主资料和业主物品
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2018/12/19 14:37
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean updateHousing(Map<String, Object> params) {
        boolean result = false;
        //所有新增处理
        Map<String, Object> commonInsertParms = new HashMap<String, Object>();
        commonInsertParms.put("by", ContextUtils.getUserId());//操作人
        commonInsertParms.put("term", "2");// 创建端 Insert端： 1 租客端 2市场部 3 工程部   4运营部   5财务部  6总经办 7发展部
        commonInsertParms.put("fnc",
                this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
        ParamsCommon.commonInsertParms(commonInsertParms);
        //所有修改处理
        Map<String, Object> commonUpdateParms = new HashMap<String, Object>();
        commonUpdateParms.put("by", ContextUtils.getUserId());//操作人
        commonUpdateParms.put("term", "2");// 创建端 Insert端： 1 租客端 2市场部 3 工程部   4运营部   5财务部  6总经办 7发展部
        commonUpdateParms.put("fnc",
                this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
        ParamsCommon.commonUpdateParms(commonUpdateParms);

        try {
            //房产证不动产照片
            List<Map<String, Object>> DeedFileList = (List<Map<String, Object>>) params.get("DeedFile");
            String DeedFile = FileSubufferUtils.ListTranStringUtils(DeedFileList);
            params.put("DeedFile", DeedFile);
            //房源照片
            List<Map<String, Object>> HouImgList = (List<Map<String, Object>>) params.get("HouImg");
            String HouImg = FileSubufferUtils.ListFlieStringUtils(HouImgList);
            params.put("HouImg", HouImg);
            //合同照片
            List<Map<String, Object>> ContractFileList = (List<Map<String, Object>>) params.get("ContractFile");
            String ContractFile = FileSubufferUtils.ListTranStringUtils(ContractFileList);
            params.put("ContractFile", ContractFile);
            //其他文件
            List<Map<String, Object>> RestsFileList = (List<Map<String, Object>>) params.get("RestsFile");
            String RestsFile = FileSubufferUtils.ListTranStringUtils(RestsFileList);
            params.put("RestsFile", RestsFile);
            params.putAll(commonUpdateParms);

            //修改房源主表
            housingMapper.updateHousing(params);

            //根据业主编号查询当前业主合同
            Map<String, Object> getOwnerDealOwIdMap = OwnerMapper.getOwnerDealOwIdMap(new HashMap<String, Object>() {{
                put("OwId", params.get("OwId"));
            }});

            //根据业主合同编号录入业主合同附件及业主收款人
            OwnerMapper.UpdateOwnerDeal(new HashMap<String, Object>() {{
                put("OwDeId", getOwnerDealOwIdMap.get("OwDeId"));
                put("FirstPayment", params.get("FirstPayment"));
                put("SecondPayment", params.get("SecondPayment"));
                put("Payee", params.get("Payee"));
                put("PayBank", params.get("PayBank"));
                put("PayAccount", params.get("PayAccount"));
                put("ContractFile", ContractFile);
            }});

            //房源业主其他资料
            List<Map<String, Object>> ownerList = (List<Map<String, Object>>) params.get("ownerList");

            housingOwnerMapper.delectHousingOwner(params);

            for (Map<String, Object> map : ownerList) {
                List<Map<String, Object>> IdnoImgsList = (List<Map<String, Object>>) map.get("IdnoImgs");
                String IdnoImgs = FileSubufferUtils.ListTranStringUtils(IdnoImgsList);
                map.put("IdnoImgs", IdnoImgs);
                //查询房源业主
                Map<String, Object> houOwId = utilsMapper.getUUID(new HashMap<String, Object>() {{
                    put("uuid", "HouOwId");
                    put("database", Constants.DATA_SOURCE_TCMKT);
                    put("surface", "tcmkt_housing_owner");
                }});
                if (houOwId != null) {
                    int number = Integer.valueOf(houOwId.get("uuid").toString());
                    HouOwId = ComUtils.getLocalTrmSeqNum("fyow", number);
                } else {
                    HouOwId = ComUtils.getLocalTrmSeqNum("fyow", 0);
                }

                map.put("HouOwId", HouOwId);
                housingOwnerMapper.AddHousingOwner(map);
            }

            //房源业主物品
            List<Map<String, Object>> owners = (List<Map<String, Object>>) params.get("owners");
            if (owners.size() > 0) {
                for (Map<String, Object> map : owners) {
                    //判断是否有id
                    if (!FieldCheckUtil.isMapFieldNotNull(map, new String[]{"id"})) {
                        if (!map.get("Number").equals(0)) {
                            map.put("HouId", params.get("HouId"));
                            map.putAll(commonInsertParms);
                            housingOwnersMapper.AddHousingOwners(map);
                        }
                    } else {
                        map.putAll(commonUpdateParms);
                        housingOwnersMapper.updateHousingOwners(map);
                    }
                }
            }

            //修改盈利预测编号
            profitMapper.updateProfit(new HashMap<String, Object>() {{
                put("ProId", params.get("ProId"));
                put("FirstPayment", params.get("FirstPayment"));
                put("SecondPayment", params.get("SecondPayment"));
                put("ProState", 6);//状态 状态 1草稿 2待审核 3驳回 4审核通过 5放弃（失效） 6房源收录草稿箱
            }});

            //根据业主编号和房源编号清空当前业主-租金递增周期
            OwnerMapper.DeleteOwnerRent(new HashMap<String, Object>() {{
                put("OwId", params.get("OwId"));
                put("HouId", params.get("HouId"));
            }});

            //业主租金变化时间点
            List<String> ownerDeal1 = (List<String>) params.get("ownerDeal1");
            log.info("ownerDeal1----" + ownerDeal1);
            for (String str : ownerDeal1) {
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("OwId", params.get("OwId"));
                map.put("HouId", params.get("HouId"));
                map.put("Increasing", 1);//递增周期类型    1.租金变化时间点   2.原始租金   3.递增后租金
                map.put("Worth", str);
                map.put("Operator", ContextUtils.getUserId());
                map.put("OperTime", ConvertDateTime.getCurrentTime());
                map.putAll(commonInsertParms);
                //新增业主-租金递增周期
                OwnerMapper.AddOwnerRent(map);
            }
            //原始租金
            List<Integer> ownerDeal2 = (List<Integer>) params.get("ownerDeal2");
            log.info("ownerDeal2----" + ownerDeal2);
            for (Integer str : ownerDeal2) {
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("OwId", params.get("OwId"));
                map.put("HouId", params.get("HouId"));
                map.put("Increasing", 2);//递增周期类型    1.租金变化时间点   2.原始租金   3.递增后租金
                map.put("Worth", str);
                map.put("Operator", ContextUtils.getUserId());
                map.put("OperTime", ConvertDateTime.getCurrentTime());
                map.putAll(commonInsertParms);
                //新增业主-租金递增周期
                OwnerMapper.AddOwnerRent(map);
            }
            //增涨租金
            List<Integer> ownerDeal3 = (List<Integer>) params.get("ownerDeal3");
            log.info("ownerDeal3----" + ownerDeal3);
            for (Integer str : ownerDeal3) {
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("OwId", params.get("OwId"));
                map.put("HouId", params.get("HouId"));
                map.put("Increasing", 3);//递增周期类型    1.租金变化时间点   2.原始租金   3.递增后租金
                map.put("Worth", str);
                map.put("Operator", ContextUtils.getUserId());
                map.put("OperTime", ConvertDateTime.getCurrentTime());
                map.putAll(commonInsertParms);
                //新增业主-租金递增周期
                OwnerMapper.AddOwnerRent(map);
            }

            result = true;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        return result;
    }

    /**
     * 功能描述:
     * 选择完配置之后新增房源详表
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2018/12/19 19:24
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean AddHousingInfo(Map<String, Object> params) {
        boolean result = false;
        lock.lock();
        //所有新增处理
        Map<String, Object> commonInsertParms = new HashMap<String, Object>();
        commonInsertParms.put("by", ContextUtils.getUserId());//操作人
        commonInsertParms.put("term", "2");// 创建端 Insert端： 1 租客端 2市场部 3 工程部   4运营部   5财务部  6总经办 7发展部
        commonInsertParms.put("fnc",
                this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
        ParamsCommon.commonInsertParms(commonInsertParms);

        //所有修改处理
        Map<String, Object> commonUpdateParms = new HashMap<String, Object>();
        commonUpdateParms.put("by", ContextUtils.getUserId());//操作人
        commonUpdateParms.put("term", "2");// 创建端 Insert端： 1 租客端 2市场部 3 工程部   4运营部   5财务部  6总经办 7发展部
        commonUpdateParms.put("fnc",
                this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
        ParamsCommon.commonUpdateParms(commonUpdateParms);
        try {
//            Map<String,Object>uuid=utilsMapper.getUUID(new HashMap<String,Object>(){{
//                put("uuid", "HouInfoId");
//                put("database", Constants.DATA_SOURCE_TCMKT);
//                put("surface", "tcmkt_housing_info");
//            }});
//            if(uuid!=null){
//                int number=Integer.valueOf(uuid.get("uuid").toString());
//                UUID= ComUtils.getLocalTrmSeqNum("fyxq",number);
//            }else{
//                UUID=ComUtils.getLocalTrmSeqNum("fyxq",0);
//            }
            // 先判断房源类型，整租还是合租，整租就只生成一个整租房源。合租就生成整租+房间数房源
            // 房源租赁类型 1.合租 2.整租
            try {
                if (params.get("ProOperaType").equals(2)) {

                    List<Map<String, Object>> PalHouList = (List<Map<String, Object>>) params.get("PalHouList");
                    int zhengzu = 0;
                    for (Map<String, Object> map : PalHouList) {
                        int zhengzuone = 0;
                        List<Map<String,Object>> PalHouInfoList = (List<Map<String,Object>>) map.get("PalHouInfoList");
                        for (Map<String,Object> map1: PalHouInfoList) {

                            String ComNameOne = MapUtils.getString(map1,"ComName");
                            if (ComNameOne.indexOf("蜂电")!=-1||ComNameOne.indexOf("大华")!= -1){
                                zhengzuone++;
                            }
                        }
                        zhengzu = zhengzu+zhengzuone;
                        }

                    if (zhengzu>0){
                        params.put("Payment",0);
                    }else{
                        params.put("Payment",1);
                    }

                    housingMapper.AddHousingInfo(new HashMap<String, Object>() {{
                        put("HouInfoId", params.get("HouCon") + "Z");
                        put("cod", "Z");
                        put("HouInfoName", params.get("ComName").toString() + "·" + params.get("RoomsNum") + "居室·整租");
                        put("HouId", params.get("HouId"));
                        put("IfOperaType", 1);//是否是整租 0否 1是
                        put("Payment",params.get("Payment"));
                        put("HouConId", params.get("HouId") + "Z");
                        putAll(commonInsertParms);
                    }});
                } else {
                    //房源房间
                    int couuttt = 0;
                    List<Map<String, Object>> PalHouList = (List<Map<String, Object>>) params.get("PalHouList");
                    for (Map<String, Object> map : PalHouList) {
                        //排除公共区域
                        if (map.get("HouConType").equals(2)) {
                            List<Map<String,Object>> PalHouInfoList = (List<Map<String,Object>>) map.get("PalHouInfoList");
                           int Countt = 0;
                            for (Map<String,Object> map1: PalHouInfoList) {
                                String ComNameOne = MapUtils.getString(map1,"ComName");
                                if (ComNameOne.indexOf("蜂电")!=-1||ComNameOne.indexOf("大华")!= -1){
                                    Countt++;
                                }
                            }
                            couuttt = couuttt+Countt;
                            if (Countt>0){
                                map.put("Payment",0);
                            }else{
                                map.put("Payment",1);
                            }

                            housingMapper.AddHousingInfo(new HashMap<String, Object>() {{
                                put("HouInfoId", params.get("HouCon").toString() + map.get("cod").toString());
                                put("cod", map.get("cod").toString());
                                put("HouInfoName", params.get("ComName").toString() + "·" + params.get("RoomsNum") + "居室" + "·" + map.get("cod").toString());
                                put("HouId", params.get("HouId"));
                                put("Payment",map.get("Payment"));
                                put("IfOperaType", 0);//是否是整租 0否 1是
                                put("HouConId", map.get("HouConId"));
                                putAll(commonInsertParms);
                            }});
                        }
                    }
                    if (couuttt>0){
                        params.put("Payment",0);
                    }else{
                        params.put("Payment",1);
                    }
                    //然后在生成一个整租
                    housingMapper.AddHousingInfo(new HashMap<String, Object>() {{
                        put("HouInfoId", params.get("HouCon") + "Z");
                        put("cod", "Z");
                        put("HouInfoName", params.get("ComName").toString() + "·" + params.get("RoomsNum") + "居室·整租");
                        put("HouId", params.get("HouId"));
                        put("Payment",params.get("Payment"));
                        put("IfOperaType", 1);//是否是整租 0否 1是
                        put("HouConId", params.get("HouId") + "Z");
                        putAll(commonInsertParms);
                    }});
                }
                //修改房源主表
                housingMapper.updateHousing(new HashMap<String, Object>() {{
                    put("HouId", params.get("HouId"));
                    put("State", params.get("State"));
                    putAll(commonUpdateParms);
                }});
                profitMapper.updateProfit(new HashMap<String, Object>() {{
                    put("ProId", params.get("ProId"));
                    //状态   状态   1草稿  2待审核  3驳回   4审核通过  5放弃（失效）  6房源收录草稿箱  7房源收录成功
                    put("ProState", 7);
                    putAll(commonUpdateParms);
                }});
                result = true;

                //查询房源项目编号 和 分割间数
                //发起通知
                Map<String, Object> proMap = profitMapper.getProfitDataMap(MapUtils.getString(params, "ProId"));
                //通知
                CustomMap data = CustomMap.create("MeType", 13)
                        .put("Title", "新收房源")
                        .put("Content", HtmlUtil.stringToHTML(String.format("注意！有新收录的房源(%s-%d)请及时跟进！", MapUtils.getString(proMap, "ComName"), MapUtils.getInteger(proMap, "RoomsNum")), "", Color.blue))
                        .put("by", ContextUtils.getUserId())
                        .put("term", 3);
                feignZull.AddMessage(data);


                data = CustomMap.create("MeType", 11)
                        .put("Title", "待分配管家")
                        .put("Content", HtmlUtil.stringToHTML("注意！有新的房源待分配服务管家 请及时处理！", "", Color.blue))
                        .put("by", ContextUtils.getUserId())
                        .put("term", 3);
                feignZull.AddMessage(data);
            } catch (Exception e) {
                e.printStackTrace();
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            }
        } finally {
            lock.unlock();
        }
        return result;
    }

    /**
     * 功能描述:
     * 根据工程部查询已变更房源配置的房源查询市场部房源列表
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2018/12/26 9:46
     */
    public List<Map<String, Object>> getHousingPlanAmendList(Map<String, Object> params) {
        List<Map<String, Object>> getHousingPlanAmendList = housingMapper.getHousingPlanAmendList(params);
        for (Map<String, Object> map : getHousingPlanAmendList) {
            if (!StringUtils.isBlank(MapUtils.getString(map, "BuilDing"))) {
                if (StringUtils.isBlank(MapUtils.getString(map, "Room"))) {
                    map.put("BuilDingRoom", map.get("BuilDing").toString() + "号");
                } else {
                    map.put("BuilDingRoom", map.get("BuilDing").toString() + "号" + map.get("Room").toString() + "室");
                }
            } else {
                map.put("BuilDingRoom", null);
            }

            if (!StringUtils.isBlank(MapUtils.getString(map, "OwLoculus"))) {
                if (!StringUtils.isBlank(MapUtils.getString(map, "OwHall"))) {
                    if (!StringUtils.isBlank(MapUtils.getString(map, "OwGuard"))) {
                        map.put("house", map.get("OwLoculus").toString() + "室" + map.get("OwHall").toString() + "厅" + map.get("OwGuard").toString() + "卫");
                    } else {
                        map.put("house", map.get("OwLoculus").toString() + "室" + map.get("OwHall").toString() + "厅");
                    }
                } else {
                    map.put("house", map.get("OwLoculus").toString() + "室");
                }
            } else {
                map.put("house", null);
            }
        }
        return getHousingPlanAmendList;
    }

    /**
     * 功能描述:
     * 根据工程部查询已变更房源配置的房源查询市场部房源列表总数
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2018/12/26 9:47
     */
    public Integer getHousingPlanAmendListCoun(Map<String, Object> params) {
        Integer getHousingPlanAmendListCoun = housingMapper.getHousingPlanAmendListCoun(params);
        return getHousingPlanAmendListCoun;
    }

    /**
     * 功能描述:
     * 补充运营部业主提前收房
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/1/12 20:41
     */
    public Map<String, Object> getHousingOwLists(Map<String, Object> params) {
        log.info("params---" + params);
//        log.info("date---"+ ObjectUtil.convertObjectToMap(params.get("dataList")));
//        CustomMap map=new CustomMap();
        Map<String, Object> result = new HashMap<String, Object>();
//        map=ObjectUtil.convertObjectToMap(params.get("dataList"));
        List<Map<String, Object>> dateList = (List<Map<String, Object>>) params.get("dataList");
        log.info("dateList运营部---" + dateList);
        if (dateList.size() > 0) {
            for (Map<String, Object> maps : dateList) {
                log.info("maps----------" + maps);
                Map<String, Object> getHousingOwadvance = housingMapper.getHousingOwadvance(maps);
                if (MapUtils.isNotEmpty(getHousingOwadvance)) {
                    maps.putAll(getHousingOwadvance);
                }
                if (!StringUtils.isBlank(MapUtils.getString(maps, "BuilDing"))) {
                    if (StringUtils.isBlank(MapUtils.getString(maps, "Room"))) {
                        maps.put("BuilDingRoom", maps.get("BuilDing").toString() + "号");
                    } else {
                        maps.put("BuilDingRoom", maps.get("BuilDing").toString() + "号" + maps.get("Room").toString() + "室");
                    }
                } else {
                    maps.put("BuilDingRoom", null);
                }
                if (!StringUtils.isBlank(MapUtils.getString(maps, "OwLoculus"))) {
                    if (!StringUtils.isBlank(MapUtils.getString(maps, "OwHall"))) {
                        if (!StringUtils.isBlank(MapUtils.getString(maps, "OwGuard"))) {
                            maps.put("house", maps.get("OwLoculus").toString() + "室" + maps.get("OwHall").toString() + "厅" + maps.get("OwGuard").toString() + "卫");
                        } else {
                            maps.put("house", maps.get("OwLoculus").toString() + "室" + maps.get("OwHall").toString() + "厅");
                        }
                    } else {
                        maps.put("house", maps.get("OwLoculus").toString() + "室");
                    }
                } else {
                    maps.put("house", null);
                }
            }

            List<Map<String,Object>>getPostDeptList=baseFeignZuul.getPostDeptList(new HashMap<>());
            //合并
            dateList= ListMapMergeUtil.ListMergeUtils(dateList,getPostDeptList,"DeptId");

        }
        params.put("dataList", dateList);
        result.putAll(params);
        return result;
    }

    /**
     * 功能描述:
     * 获取房源验收之后定价
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/12 20:02
     */
    public List<Map<String, Object>> getPricingHousingList(Map<String, Object> params) {
        List<Map<String, Object>> getPricingHousingList = housingMapper.getPricingHousingList(params);
        List<String> usrlist;
        for (Map<String, Object> map : getPricingHousingList) {
            usrlist = new ArrayList<String>();//创建一个list的集合
            usrlist.add(map.get("InclusionId").toString());//获取收房专员id;
            JsonResult<List<Map<String, Object>>> res = baseFeignZuul.getUserInfo(usrlist);//获取用户集合
            List<Map<String, Object>> data = res.getResult();
            map.put("username", MapUtils.getString(data.get(0), "username")); //收房专员姓名
            map.put("mobile", MapUtils.getString(data.get(0), "mobile"));//收房专员手机号码
        }
        return getPricingHousingList;
    }

    /**
     * 功能描述:
     * 获取房源验收之后定价总数
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/12 20:02
     */
    public Integer getPricingHousingListCont(Map<String, Object> params) {
        Integer getPricingHousingListCont = housingMapper.getPricingHousingListCont(params);
        return getPricingHousingListCont;
    }

    /**
     * 功能描述:
     * 根据房源编号获取定价房源详情
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/13 18:38
     */
    public Map<String, Object> getPricingHousingInfoList(Map<String, Object> params) {
        Map<String, Object> result = new HashMap<String, Object>();
        List<Map<String, Object>> getPricingHousingInfoList = housingMapper.getPricingHousingInfoList(params);
        Map<String, Object> Whole = new HashMap<String, Object>();
        List<Map<String, Object>> Scatter = new ArrayList<Map<String, Object>>();
        for (Map<String, Object> map : getPricingHousingInfoList) {
            List<Map<String, Object>> getPricingHousingConInfoList = housingMapper.getPricingHousingConInfoList(new HashMap<String, Object>() {{
                put("HouConId", map.get("HouConId"));
            }});
            map.put("HousingCon", getPricingHousingConInfoList);
            if (map.get("IfOperaType").equals(1)) {
                map.put("UnifiedPricing", null);
                Whole.putAll(map);
            } else {
                map.put("UnifiedPricing", null);
                Scatter.add(map);
            }
        }
        result.put("Whole", Whole);
        result.put("Scatter", Scatter);
        return result;
    }

    /**
     * 功能描述:
     * 获取所有房源房间
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/14 19:35
     */
    public List<Map<String, Object>> getHousingActList(Map<String, Object> params) {
        List<Map<String, Object>> getHousingActList = housingMapper.getHousingActList(params);
        return getHousingActList;
    }

    /**
     * 功能描述:
     * 获取所有房源房间总数
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/2/14 19:36
     */
    public Integer getHousingActListCount(Map<String, Object> params) {
        Integer getHousingActListCount = housingMapper.getHousingActListCount(params);
        return getHousingActListCount;
    }

    /**
     * 功能描述:
     * 装修计划判断当前已选中房源的服务中心
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/3 10:54
     */
    public Map<String, Object> getHousingMiMap() {
        Map<String, Object> getHousingMiMap = housingMapper.getHousingMiMap();
        return getHousingMiMap;
    }

    /**
     * 功能描述:
     * 获取所有房源资料(字段可扩展)
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/5 16:18
     */
    public List<Map<String, Object>> getAllHousingArrList() {
        return housingMapper.getAllHousingArrList();
    }

    /**
     * 功能描述:
     * 获取所有房源资料(字段可扩展)
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/5 16:18
     */
    public List<Map<String, Object>> getAllHousingLists() {
        return housingMapper.getAllHousingLists();
    }

    /**
     * 功能描述:
     * 根据房源配置获取所有房源资料(字段可扩展)
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/9 13:45
     */
    public List<Map<String, Object>> getAllHousingConLists() {
        return housingMapper.getAllHousingConLists();
    }

    /**
     * 功能描述:
     * 根据租客编号获取租客当前合同列表
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/10 20:48
     */
    public List<Map<String, Object>> getTenantPactList(Map<String, Object> params) {
        return housingMapper.getTenantPactList(params);
    }

    /**
     * 功能描述:
     * 运营部根据退租账单编号获取房源物品清单
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/20 10:51
     */
    public List<Map<String, Object>> getWithHouConInfoList(Map<String, Object> params) {
        return housingMapper.getWithHouConInfoList(params);
    }

    /**
     * 功能描述:
     * 获取所有房源资料(字段可扩展)
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/20 10:51
     */
    public List<Map<String, Object>> getAllComIdHousingList(Map<String, Object> params) {
        return housingMapper.getAllComIdHousingList(params);
    }


    /**
     * 根据房源编号过滤这个项目下的房源信息
     *
     * @param hIds
     * @param val
     * @param col
     * @param where
     * @return
     */
    public JsonResult selectComIdByHId(List<String> hIds, String val, String col, String where) {
        return JsonResult.success(housingMapper.selectComIdByHids(hIds, val, col, where));
    }


    /**
     * 根据房源主编号查询房源基本信息资料数据
     *
     * @param hIds
     * @return
     */
    public JsonResult selectHousingDetailByArray(List<String> hIds) {
        List<Map<String, Object>> list = housingMapper.selectHousingDetailByArray(hIds);
        for (Map<String, Object> map : list) {
            //获取服务中心名称
            Map<String, Object> dataMap = zuulFeign.getDeptInfoById(MapUtils.getString(map, "MiId"));
            String deptName = MapUtils.getString(dataMap, "name");
            if (StringUtils.isBlank(deptName)) {
                return JsonResult.error("查询服务中心异常");
            }
            map.put("centerName", deptName);

            //查询归属公司
            JsonResult<JSONObject> areaJson = zuulFeign.getAreaInfoForGSByDeptId(MapUtils.getString(map, "MiId"));
            if (!areaJson.isSuccess()) {
                return JsonResult.error("错误:" + areaJson.getErrorMessage());
            }
            String areaName = areaJson.getResult().getString("name");
            map.put("areaName", areaName);
        }
        return JsonResult.success(list);
    }


    /**
     * 查找房间号通过房源配置编号
     *
     * @param ids
     * @return
     */
    public JsonResult getHousingRoom(List<String> ids) {
        List<Map<String, Object>> list = housingMapper.selectHousingRoomByConId(ids);
        return JsonResult.success(list);
    }

    /**
     * 功能描述:
     * 根据盈利预测室号,获取所有的房源出租房间列表
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/6/20 19:36
     */
    public List<Map<String, Object>> getProByHousingInfoList(Map<String, Object> params) {
        return housingMapper.getProByHousingInfoList(params);
    }

    /**
     * 功能描述:
     * 根据服务中心编号，项目编号。楼号。房号。室号获取房源主表和房源详表
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/6/20 19:36
     */
    public List<Map<String, Object>> getMiAndComAndBuiAndRoomAndHouList(Map<String, Object> params) {
        return housingMapper.getMiAndComAndBuiAndRoomAndHouList(params);
    }

    /**
     * @description:根据房源编号查询当前房源是否有在租租客
     * @param params
     * @return java.lang.Integer
     * @author zhlu
     * @date 2019/9/17 14:42
     */
    public Integer getHouIdByRenting(Map<String, Object> params){
        return housingMapper.getHouIdByRenting(params);
    }

    /**
     * @description:业主提前收房，
     * 修改房源状态Advance：1
     * delfg：1
     * @param
     * @return boolean
     * @author zhlu
     * @date 2019/9/17 14:50
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean ownerHouse(String HouId){
        boolean result=false;
        //所有修改处理
        Map<String, Object> commonUpdateParms = new HashMap<String, Object>();
        commonUpdateParms.put("by", ContextUtils.getUserId());//操作人
        commonUpdateParms.put("term", "2");// 创建端 Insert端： 1 租客端 2市场部 3 工程部   4运营部   5财务部  6总经办 7发展部
        commonUpdateParms.put("fnc",
                this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
        ParamsCommon.commonUpdateParms(commonUpdateParms);
        try {
            //房源数据
            Map<String,Object>params=new HashMap<String,Object>();
            params.put("HouId",HouId);
            //当前房源业主是否已收房   0否   1.是（房源就不能再展示在唐巢）
            params.put("Advance",1);
            //废弃标志位     0正常 1废弃
            params.put("delfg",1);
            params.putAll(commonUpdateParms);
            //修改房源数据
            housingMapper.updateHousing(params);
            result=true;
        } catch (Exception e) {
            log.info(e.getMessage());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        return result;
    }

    /**
     * @description:根据房源编码获取当前房源的公司编码和业主合同
     * @param params
     * @return java.util.Map<java.lang.String,java.lang.Object>
     * @author zhlu
     * @date 2019/9/17 16:31
     */
    public Map<String,Object>getHouIdByOwner(Map<String,Object>params){
        return housingMapper.getHouIdByOwner(params);
    }



    public List<Map<String,Object>> getHouIncid(Map<String,Object> params){
        return housingMapper.getHouIncid(params);
    }

}
